from chromadb import HttpClient
import chromadb
try:
    print(chromadb.__version__)
    # 创建客户端连接
    client = HttpClient(host="49.7.225.191", port=8000)

    # 测试服务器心跳（基础连接测试）
    heartbeat = client.heartbeat()
    print(f"✅ 服务器心跳响应: {heartbeat}")

    # 测试集合操作
    collection = client.get_or_create_collection(name="test_connection")
    print(f"✅ 成功访问集合: {collection.name}")

    # 清理测试集合
    client.delete_collection(name="test_connection")
    print("✅ 测试完成，已清理临时集合")

except Exception as e:
    print(f"❌ 连接失败: {str(e)}")